<%--
  Created by IntelliJ IDEA.
  User: alleon
  Date: Jun 17, 2008
  Time: 1:55:23 PM
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
  <head>
      <title>Create Document from File</title>
      <g:javascript library="scriptaculous"/>
      <g:javascript src="lightbox.js"/>
      <link rel="stylesheet" href="${createLinkTo(dir:'css', file:'lightbox.css')}"/>
  </head>
  <body>
    <table width="100%">
      <g:if test="${params.dir}">
          <tr>
            <td>
              <a href="<g:createLinkTo dir="${params.cms}/list"/>?dir=${params.dir.substring(0.params.dir.lastIndexOf('/'))}">..</a>
            </td>
          </tr>
      </g:if>

      <g:each var="file" in="${files}">
        <tr>
          <td>
            <g:if test="${file.isDirectory()}">
              <a href="<g:createLinkTo dir="${params.cms}/list"/>?dir=${dirName}/${file.name}">${file.name}</a>
            </g:if>
            <g:else>
              <div id="file-${file.name}">${file.name}</div>
            </g:else>
            <g:javascript>
              new Ajax.InPlaceEditor('file-$file.name}', '<g:createLinkTo dir="${params.cms}/files/rename"/>?dir=${dirName}$filename=${file.name}')
            </g:javascript>
          </td>
          <td>
            <g:if test="${file.isFile()}">
              <a href="<g:createLinkTo dir="${params.cms}"/>${dirName}/${file.name}" rel="lightbox" title="${file.name}">
                <img src="<g:createLinkTo dir="images" file="zoom.png" alt="preview image"/>"/>
              </a>
              <a href="<g:createLinkTo dir="${params.cms}"/>${dirName}/${file.name}">
                <img src="<g:createLinkTo dir="images" file="photo.png" alt="show image"/>"/>
              </a>
              <a href="<g:createLinkTo dir="${params.cms}/delete"/>?dir=${dirName}&filename=${file.name}">
                <img src="<g:createLinkTo dir="images" file="delete.png" alt="delete image"/>"/>
              </a>
            </g:if>
          </td>
        </tr>
      </g:each>
    </table>
    <div style="">
      <form action="<g:createLinkTo dir="${params.cms}"/>/files/upload" method="post" enctype="multipart/form-data">
        File:
          <input type="hidden" name="dir" value="${dirName}"/>
          <input type="file" name="theFile"/>
        Tags:
          <input name="tags"/>
          <br></br>
          <input type="submit" value="Upload"/>
      </form>
    </div>
  </body>
</html>